﻿using ASmile.Com;
using ASmile.Com.Da;
using ASmile.Com.Search;
using ASmile.DBModel;
using Microsoft.AspNetCore.Mvc;

namespace ASmile.Web.ApiControllers.SysManage
{
    /// <summary>
    /// 高级搜索
    /// </summary>
    [Route("api/SysManage/[controller]/[action]")]
    [ApiExplorerSettings(GroupName = "SysManage")]
    public class SearchController : BaseApiController<SearchBLL>
    {
        ///// <summary>
        ///// 获取列信息
        ///// </summary>
        //[HttpPost]
        //public ApiResultList<Sys_GridColumn> GetColumns(System.Text.Json.JsonElement je)
        //{
        //    string formName = je.GetString("FormName");
        //    string dgvName = je.GetString("DgvName");
        //    return BLLObj.GetColumns(formName, dgvName);
        //}
        /// <summary>
        /// 获取默认记录
        /// </summary>
        [HttpPost]
        public ApiResult<Sys_ADRecord> GetDefRecord(ArgRecordSearch arg)
        {
            //string formName = je.GetString("FormName");
            //string dgvName = je.GetString("DgvName");
            return BLLObj.GetDefRecord(arg);
        }
        /// <summary>
        /// 指定记录Id更新缺省记录，用于无修改的搜索记录
        /// </summary>
        [HttpPost]
        public ApiResult SaveDefRecord(ArgSaveRecord arg)
        {
            return BLLObj.SaveDefRecord(arg);
        }
        /// <summary>
        /// 保存新的记录
        /// </summary>
        [HttpPost]
        public ApiResult<string> SaveRecord(ArgSaveRecord arg)
        {
            return BLLObj.SaveRecord(arg);
        }
        /// <summary>
        /// 获取搜索记录条件明细
        /// </summary>
        [HttpPost]
        public ApiResultList<Sys_ADRecord_Detail> GetRecordDetail(ArgMainId arg)
        {
            //string recordId = je.GetString("RecordId");
            return BLLObj.GetRecordDetail(arg);
        }
        /// <summary>
        /// 获取指定的所有保存的记录
        /// </summary>
        [HttpPost]
        public ApiResultList<Sys_ADRecord> GetRecordList(ArgRecordSearch arg)
        {
            return BLLObj.GetRecordList(arg);
        }
        /// <summary>
        /// 删除搜索记录及明细
        /// </summary>
        [HttpPost]
        public ApiResult DelRecord(Sys_ADRecord record)
        {
            return BLLObj.DelRecord(record);
        }
        /// <summary>
        /// 更新记录
        /// </summary>
        [HttpPost]
        public ApiResult<string> UpdateRecord(Sys_ADRecord record)
        {
            return BLLObj.UpdateRecord(record);
        }
    }
}